<?php
C_base::yn_file('base'.DS.'htmlbase.php');
class job extends htmlbase{
	var $_vpath = 'zjia/';//pc/phone文件夹下的路径
	var $_xueli = array('不限','高中以下','高中','中专/技校','大专','本科','硕士','博士','MBA/EMBA');
	var $_gzjy = array('应届生','一年','两年','三年','三年-五年','五年-十年','十年以上');
	var $_waiyu = array('不限','英语','日语','法语','韩语','德语','泰语','西班牙语','俄语','意大利语','葡萄牙语','斯瓦西里语','阿拉伯语','马来语','瑞典语','塞尔威亚语','波斯语','越南语','芬兰语','乌克兰语','捷克语','阿尔巴尼亚语','波兰语','缅甸语','僧伽罗语','豪萨语','印地语');
	var $xz = array('面议','1000元以下','1000-2000元','2000-3000元','3000-5000元','5000-8000元','8000-10000元','10000元以上');
	var $_yysp = array('不限','基础水平','独立运用','熟练运用');
	var $_cskill = array('不限','一般','熟练','精通');
	var $sex = array('保密','男','女');
	var $zjid;
	var $uid;
	function __construct(){
		parent::__construct();
		$this->zjid = @$this->Ses('recruit_zjid') ? $this->Ses('recruit_zjid') : '';
		$this->uid = @$this->Ses('recruit_uid') ? $this->Ses('recruit_uid') : '';
		$this->kid = @$this->Ses('recruit_uid') ? $this->Ses('recruit_uid') : @$this->Ses('recruit_zjid');
	}

/****************************************专家登陆，退出 个人中心****************************************/
	function sfdl_zjia(){//判断专家是否登录
		if(!@$this->Ses('recruit_zjid')){
			$this->_alert_location($this->_url.'/?act=job&met=zjdl','请先登录');
		}else{
			$cha = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
			if($cha['dongjie'] == 1){//账户户被冻结
				$this->_alert_location($this->_url.'/?act=job&met=zjdl','账号被冻结，不能登录');
			}
		}
	}
	
	function zjtc(){//退出
		$this->_is_html =1;
		C_base::M('admin.recruit')->user_u(array('id'=>$this->zjid),array('socket_id'=>0,'ltlx'=>2));
		C_base::M('admin.recruit')->room_del(array('room'=>$this->zjid));
		if(@!$this->_post('type')){
			$this->Ses('recruit_zjid','');
			$this->Ses('recruit_zjname','');
			$this->Ses('recruit_type','');
			$this->Ses('zclx','');
			$this->_alert_location($this->_url.'/?act=job&met=zjdl');
		}		
	}
	
	/**
	 * 完善资料
	 */
	function wszl(){
		$this->sfdl_zjia();
		if($this->Ses('zclx') == 2){
			$ck = C_base::M('admin.recruit')->vbase_s(array('uid'=>$this->zjid));
		}else{
			$ck = C_base::M('admin.recruit')->ubase_s(array('uid'=>$this->zjid));
		}
		if(!@$ck){
			$this->_alert_location($this->_url.'/?act=job&met=vipzjzl','请先完善专家信息');
		}
	}
	
	/**
	 * name 账号
	 * pass 密码
	 */
	function zjdl(){
		$this->title = '专家登录';
		@$this->name = $this->cookie('name');
		@$this->pass = $this->cookie('pass');
	}
	
	/**
	 * name 用户名
	 * pass 密码
	 */
	function zjdl_sck(){
		extract($this->_post());
		if(!@$name){
			exit('请输入用户名');
		}elseif(!@$pass){
			exit('请输入密码');
		}
		$cha = C_base::M('admin.recruit')->user_s(array('phone'=>$name,'pass'=>md5($pass),'lx!'=>0));
		if(!@$cha){
			$cha = C_base::M('admin.recruit')->user_s(array('email'=>$name,'pass'=>md5($pass),'lx!'=>0));
		}
		if(@$cha){
			if($cha['dongjie'] != 1){
				$this->Ses('recruit_uid','');
				$this->Ses('firm_id','');
				$this->Ses('recruit_type',3);
				$this->Ses('recruit_zjid',$cha['id']);//专家id
				$this->Ses('recruit_zjname',$name);//专家id
				$this->Ses('zclx',$cha['lx']);//1普通2vip
				if(@$zd){
					$this->cookie('name',$name);
					$this->cookie('pass',$pass);
				}
				C_base::M('admin.recruit')->user_u(array('id'=>$cha['id']),array('id'=>$cha['id'],'dltime'=>time(),'ltlx'=>2));
				C_base::M('admin.recruit')->room_del(array('room'=>$this->Ses('recruit_zjid')));
				exit('cg');
			}else{
				exit('账号被冻结，不能登录');//用户被冻结
			}
		}else{
			exit('账号或密码错误');
		}
	}
	
	function pdwk($str){
		$na = mb_ereg_replace('^(　| )+','', $str);//去除全角字符的空格
		$nam = mb_ereg_replace('(　| )+$','', $na);//去除全角字符的空格
		return $nam;
	}
	/**
	 * 账号信息
	 */
	function zzxx($uid){
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$uid));
		$yhm = @$yh['phone'] ? $yh['phone'] : @$yh['email'];
		if (@$yh['lx']== 2){
			$base = C_base::M('admin.recruit')->vbase_s(array('uid'=>$uid));
			if($base){
				$base['qy_name'] = @$base['byyx'] ? $base['byyx'] : 'VIP专家';
			}
			$base['qyname'] = @$base['name'] ? $base['name'] : $yhm;
		}else{
			$base = C_base::M('admin.recruit')->ubase_s(array('uid'=>$uid));
			if(@$yh['qyid']){
				$qy = C_base::M('admin.recruit')->qys_s(array('uid'=>$yh['qyid']));
				$base['qyname'] = $base['qy_name'] = @$qy['qy_name'];
				$base['qyid'] = $yh['qyid'];
			}
		}
		
		$base['yname'] = @$base['name'] ? $base['name'] : $yhm;
		return $base;
	}
	
	/**
	 * 专家个人中心
	 */
	function index(){
		$this->sfdl_zjia();
		$this->title='专家中心';
		$this->yh= C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		if(@!$this->yh['qyid'] && $this->yh['lx'] == 1){
			$this->_alert_location($this->_url.'/?act=job&met=zjdl','用户异常,联系客服');
		}
		$base = self::zzxx($this->zjid);
		if($this->yh['lx'] == 2){
			$this->yh['qyname'] = $this->user_name($this->zjid);
		}else{
			$this->yh['qyname'] = @$base['qyname'];
		}
		$this->yh['touxiang'] = @$base['touxiang'];
		//获取专家发布的课程数 和 岗位数
		$this->tongji = C_base::M('admin.recruit')->zjtongji_s(array('zjid'=>$this->zjid));
		//最新人才推荐
		$rr = array();
		for($i=0;$i<=9;$i++){
			$rr[$i] = C_base::M('admin.recruit')->resume_ss_p($i,array('type'=>0),'1','10');
		}
		if(@$rr){
			foreach ($rr as $k=>$v){
				if(@$v){
					foreach ($v as $k1=>$v1){
						$zw = C_base::M('admin.recruit')->job_s(array('id'=>$v1['zhiwei']));
						if($zw){
							$users[$k1] = $v1;
							$users[$k1]['zw'] = $zw['name'];
						}
					}
				}
			}
		}

		if(@$users){
			$this->users = self::tiqu('10',@$users,'utime');
			$this->rcount = count($this->users);
		}	
	}
	
	function tiqu($lie,$rrs,$type=''){//3 2
		if($rrs){
			if(count($rrs) <= $lie){//如果剩下的条数小于等于要筛选的条数，直接获取
				$rs = $rrs;
			}elseif(count($rrs) > $lie){
				$rs = array_slice($rrs, 0,10);
			}else{
				$rs = array();
			}
			if(@$rs){
				$rs = util::unique_arr($rs,true);//去重
				$rs = util::paixu($rs,$type,'desc');//排序
			}
			return $rs;
		}
	}
	/**
	 * 普通专家基本信息
	 */
	function ptzjzl(){
		$this->sfdl_zjia();
		$this->title = '基本信息-修改资料';
		$this->r = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		$this->rs = C_base::M('admin.recruit')->ubase_s(array('uid'=>$this->zjid));
		$this->zhuany = C_base::M('admin.recruit')->major_ss();
		$this->sh = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));//所有省列表
		if(@$this->rs['xsheng']){
			$this->shi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['xsheng']));
			if(@$this->rs['xshi']){
				$this->qu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['xshi']));
			}
		}
		if(@$this->rs['hksheng']){
			$this->hkshi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['hksheng']));
			if(@$this->rs['hkshi']){
				$this->hkqu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->rs['hkshi']));
			}
		}
	}
	/**
	 * 专家 修改资料
	 * type 存在，修改vip
	 */
	function pt_xgzl(){
		$this->_is_html=1;
		$this->sfdl_zjia();
		$post = $this->_post();
		extract($this->_post());
		$type = @$this->_get('type');
		if(@$type){
			$this->xgzl_pd($this->_post());
		}else{
			C_base::con('html.ruser')->xgzl_pd($this->_post());
			if(@$bytime){
				$post['bytime'] = strtotime($bytime);
			}
		}
		if(@$cstime){
			$post['cstime'] = strtotime($cstime);
		}
		$tj = array('uid'=>$this->zjid);
		if(@$type){
			$pd = C_base::M('admin.recruit')->vbase_s($tj);
		}else{
			$pd = C_base::M('admin.recruit')->ubase_s($tj);
		}		
		if($pd){
			if(@$type){
				$aa = C_base::M('admin.recruit')->vbase_u($tj,$post);
			}else{
				$aa = C_base::M('admin.recruit')->ubase_u($tj,$post);
			}
		}else{
			$c = array_merge($post,$tj);
			if(@$type){
				$aa = C_base::M('admin.recruit')->vbase_c($c);
			}else{
				$aa = C_base::M('admin.recruit')->ubase_c($c);
			}
		}
		if($aa){
			exit('修改成功');
		}else{
			exit('系统繁忙');
		}
	}
	/**
	 * vip专家基本信息
	 */
	function vipzjzl(){
		$this->sfdl_zjia();
		$this->title = '基本信息';
		$this->user = self::zzxx($this->zjid);
		$this->sh = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));//所有省列表
		if(@$this->user['xsheng']){
			$this->shi = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->user['xsheng']));
			if(@$this->user['xshi']){
				$this->qu = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$this->user['xshi']));
			}
		}
		$this->sfzsmj = C_base::dybase('util')->tpname(@$this->user['sfzsmj']);
		$this->gzzmsmj = C_base::dybase('util')->tpname(@$this->user['gzzmsmj']);
	}

	function xgzl_pd($post){
		extract($post);
		$time = date('Y-m-d',time());//当前日期
		if(!@$name){
			exit('请填写姓名');
		}elseif(@$sex == ''){
			exit('请选择性别');
		}elseif(!@$cstime){
			exit('请填写出生日期');
		}elseif(@$cstime && ($cstime > $time)){
			exit('请正确填写出生日期');
		}elseif(!@$xsheng || !@$xshi/*  || !@$xsq */){
			exit('请填写现居住地');
		}elseif(!@$sfzh){
			exit('请填写身份证号');
		}elseif(!util::preg_sfzh($sfzh)){
			exit('身份证号格式错误');
		}elseif (!@$scly){
			exit('请填写擅长领域');
		}elseif(@$scly){
			$nam = self::pdwk(@$scly); //判断名称
			$cd=(strlen(trim($nam)) + mb_strlen(trim($nam),'UTF8'))/2;
			if ($cd > 600) {
				exit('擅长领域不能超过600个字符(300个字)');
			}
		}elseif (!@$zycj){
			exit('请填写主要成就');
		}elseif(@$zycj){
			$nam = self::pdwk(@$zycj); //判断名称
			$cd=(strlen(trim($nam)) + mb_strlen(trim($nam),'UTF8'))/2;
			if ($cd > 600) {
				exit('主要成就不能超过600个字符(300个字)');
			}
		}
	}

	function zj_txsc(){
		$this->title = '上传头像';
		$this->sfdl_zjia();
		$this->user = self::zzxx($this->zjid);
	}
	
	
/*********************************修改/找回密码***************************************/
	function zhmm_yx(){
		$this->title='邮箱找回密码';
	}
	
	function zhmm_sj(){
		$this->title='手机找回密码';
	}
	
	/**
	 * 找回密码
	 * name 账号
	 * pass 密码1
	 * pass1 确认密码
	 * yzm 验证码
	 * type 1手机 2邮箱
	 */
	function zhaohui(){
		$this->_is_html=1;
		extract($this->_post());
		if(!@$name){
			exit('请填写账号');
		}elseif(!@$yzm){
			exit('请填写验证码');
		}
		if($type == 1){//手机
			$w = array('phone'=>$name);
		}elseif($type == 2){//邮箱
			$w = array('email'=>$name);
		}else{
			exit('非法操作');
		}
		if(!@$pass || !@$pass1){
			exit('请填写密码');
		}elseif(!util::preg_pass($pass)){
			exit('请正确填写密码，密码由字母和数字组合且长度在6-12个字符之间');
		}elseif($pass != $pass1){
			exit('两次密码不一致');
		}else{
			$user = C_base::M('admin.recruit')->user_s($w);
			if(@$user){
				if($user['lx'] ==2){
					exit('vip专家不可修改密码，需联络客服进行修改');
				}
				if($user['dongjie'] == 1){
					exit('此账号已冻结');
				}elseif(($type == 1 && util::preg_phone($name)) || ($type == 2 && util::preg_email($name))){//验证账号是否合法
					$yz = C_base::M('admin.base')->yzm_s(array('uid'=>$user['id'],'zhanghao'=>$name,'yzm'=>$yzm));
					if(@$yz){
						if((@$yz['time']+120) < time()){//如果验证码超过120秒，则失效
							exit('验证码已失效，请重新验证');
						}else{
							$a = C_base::M('admin.recruit')->user_u(array('id'=>$user['id']),array('pass'=>md5($pass)));
							if($a){
								C_base::M('admin.base')->yzm_d(array('id'=>$yz['id']));
								if($a){
									exit('重置成功');
								}else{
									exit('系统繁忙');
								}
							}else{
								exit('系统繁忙');
							}
						}
					}else{
						exit('验证码错误');
					}
				}else{
					exit('请正确填写账号');
				}
			}else{
				exit('请正确填写账号');
			}
		}
	}
	
	/**
	 * 发送验证码
	 * lx = 1 找回密码
	 */
	function fsyzm(){
		$this->_is_html=1;
		extract($this->_post());
		if(!@$name){
			exit('请填写账号');
		}
		if(@$lx == 1){//找回密码
			if($type == 1){//手机
				$w = array('phone'=>$name);
			}elseif($type == 2){//邮箱
				$w = array('email'=>$name);
			}else{
				exit('非法操作');
			}
			$user = C_base::M('admin.recruit')->user_s($w);
			if(!$user){
				exit('请正确填写账号');
			}
		}elseif(@$lx == 2){//修改手机/邮箱验证
			$this->sfdl_zjia();
			if($type == 1){//修改邮箱验证手机
				$user = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid,'phone'=>$name));
			}elseif($type == 2){//修改手机验证邮箱
				$user = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid,'email'=>$name));
			}else{
				exit('非法操作');
			}
			if(!$user){
				exit('账号错误');
			}
		}elseif(@$lx == 3){//修改手机/邮箱【添加】
			$this->sfdl_zjia();
			if($type == 1){//手机
				$w = array('phone'=>$name);
			}elseif($type == 2){//邮箱
				$w = array('email'=>$name);
			}else{
				exit('非法操作');
			}
			$user = C_base::M('admin.recruit')->user_s($w);
			if(@$user){
				exit('此账号已存在');
			}
		}else{
			exit('error');
		}
		if(($type == 1 && util::preg_phone($name)) || ($type == 2 && util::preg_email($name))){//验证账号是否合法
			$cha = C_base::M('admin.base')->yzm_s(array('zhanghao'=>$name));
			if(@$cha && (@$cha['time']+60) > time()){
				exit('对不起， 发送验证码时间间隔不能少于60秒');
			}
			$yzm=util::rand_sum('9',6);  //验证码
			if(@$lx == 1){
				$tj = array('uid'=>$user['id'],'zhanghao'=>$name,'yzm'=>$yzm,'time'=>time());
			}elseif(@$lx == 2 || @$lx == 3){
				$tj = array('uid'=>$this->zjid,'zhanghao'=>$name,'yzm'=>$yzm,'time'=>time());
			}else{
				$tj = array('zhanghao'=>$name,'yzm'=>$yzm,'time'=>time());
			}
			$zz=C_base::con('html.ruser')->yzm_u($tj);
			if($zz){
				$content='您本次的验证码为'.$yzm.'，有效时间：120秒。';
				if($type == 1){
					$args = array('shouji'=>$name,'content'=>$content,'yzm'=>$yzm);
					$aa=util::shouji_send($args);
				}else{
					$args = array('email'=>$name,'content'=>$content,'nickname'=>$name,'title'=>'邮箱注册验证');
					$aa=util::mail_send($args);
				}
				if($aa){
					$this->cookie('name',$name);
					$this->cookie('pass','');
					exit('发送成功');
				}else{
					exit('发送失败');
				}
			}else{
				exit('系统繁忙');
			}
		}else{
			exit('请正确填写账号');
		}
	}
	
	function zj_xgmm(){
		$this->title = '修改密码';
		$this->sfdl_zjia();
	}
	
	/**
	 * 密码修改验证
	 * lpass 原密码
	 * xpass 新密码
	 * xpass1 确认新密码
	 */
	function zj_xgmmsck(){
		$this->_is_html=1;
		$this->sfdl_zjia();
		extract($this->_post());
		$a = array('id'=>$this->zjid);
		$aa = C_base::M('admin.recruit')->user_s($a);
		if($aa['pass'] != @md5($lpass)){
			exit('原密码错误');
		}
		if($xpass == '' || $xpass1 == ''){
			exit('新密码不能为空');
		}
		if(@$xpass && @$xpass1){
			if($xpass == $xpass1){
				if($xpass == $lpass){
					exit('新密码不能与原密码相同');
				}elseif($xpass != $xpass1){
					exit('两次密码不一致');
				}elseif(!util::preg_pass($xpass)){
					exit('请正确填写密码，密码由字母和数字组合且长度在6-12个字符之间');
				}else{
					$bb = C_base::M('admin.recruit')->user_u(array('id'=>$aa['id']),array('pass'=>md5($xpass)));
					if(@$bb){
						$this->Ses('recruit_zjid','');
						$this->Ses('recruit_zjname','');
						$this->Ses('zclx','');
						$this->Ses('recruit_type','');
						$this->cookie('pass','');
						exit('修改成功');
					}else{
						exit('修改失败');
					}
				}
			}else{
				exit('两次密码不一致');
			}
		}else{
			exit('密码不能为空');
		}
	}
	
	function zj_xgtx(){//修改头像
		$this->_is_html=1;
		$this->sfdl_zjia();
		extract($this->_post());
		if(!@$touxiang){
			exit('请选择上传照片');
		}
		$tj = array('uid'=>$this->zjid);
		$pd = $this->zzxx($this->zjid);
		if($pd){
			if(@$this->Ses('zclx') == 1){
				$aa = C_base::M('admin.recruit')->ubase_u($tj,array('touxiang'=>$touxiang));
			}else{
				$aa = C_base::M('admin.recruit')->vbase_u($tj,array('touxiang'=>$touxiang));
			}
		}else{
			$c = array_merge(array('touxiang'=>$touxiang),$tj);
			if(@$this->Ses('zclx') == 1){
				$aa = C_base::M('admin.recruit')->ubase_c($c);
			}else{
				$aa = C_base::M('admin.recruit')->vbase_c($c);
			}
		}
		if($aa){
			exit('上传成功');
		}else{
			exit('系统繁忙');
		}
	}
	
	function zj_xgsj(){
		$this->title = '修改手机';
		$this->rs = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
	}
	
	function zj_xgyx(){
		$this->title = '修改邮箱';
		$this->rs = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
	}
	
	function xgyz(){//修改手机/邮箱验证
		$this->_is_html=1;
		$this->sfdl_zjia();
		extract($this->_post());
		if(!@$name){
			exit('请填写账号');
		}elseif(!@$type){
			exit('请选择验证方式');
		}elseif(!@$yzm){
			exit('请填写验证码');
		}
		if($type == 1){//手机
			$w = array('id'=>$this->zjid,'phone'=>$name);
		}elseif($type == 2){//邮箱
			$w = array('id'=>$this->zjid,'email'=>$name);
		}else{
			exit('非法操作');
		}
		$pd = C_base::M('admin.recruit')->user_s($w);
		if($pd){
			$yy = array('uid'=>$this->zjid,'zhanghao'=>$name,'yzm'=>$yzm);
			$yz = C_base::M('admin.base')->yzm_s($yy);
			if($yz){
				if((@$yz['time']+120) < time()){//如果验证码超过120秒，则失效
					exit('验证码已失效，请重新验证');
				}else{
					C_base::M('admin.base')->yzm_d(array('id'=>$yz['id']));
					if(@$lx == 1){//手机
						$this->Ses('recruit_zjia_sj',1);
					}elseif(@$lx == 2){//邮箱
						$this->Ses('recruit_zjia_yx',1);
					}
					exit('验证成功');
				}
			}else{
				exit('验证码错误');
			}
		}else{
			exit('账号错误');
		}
	}
	
	function xgtj(){//修改手机/邮箱提交
		$this->_is_html=1;
		$this->sfdl_zjia();
		extract($this->_post());
		$user = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		if(!@$type){
			exit('非法操作');
		}elseif(@$user['phone'] && ($type == 1) && !@$this->Ses('recruit_zjia_sj')){
			exit('非法操作');
		}elseif(@$user['email'] && ($type == 2) && !@$this->Ses('recruit_zjia_yx')){
			exit('非法操作');
		}elseif(!@$name){
			exit('请填写账号');
		}elseif(!@$yzm){
			exit('请填写验证码');
		}elseif(($type == 1) && !util::preg_phone($name)){
			exit('手机格式错误');
		}elseif(($type == 2) && !util::preg_email($name)){
			exit('邮箱格式错误');
		}
		if($type == 1){//手机
			$w = array('phone'=>$name);
		}elseif($type == 2){
			$w = array('email'=>$name);
		}else{
			exit('非法操作');
		}
		$pd = C_base::M('admin.recruit')->user_s($w);
		if(!@$pd){
			$yy = array('uid'=>$this->zjid,'zhanghao'=>$name,'yzm'=>$yzm);
			$yz = C_base::M('admin.base')->yzm_s($yy);
			if($yz){
				if((@$yz['time']+120) < time()){//如果验证码超过120秒，则失效
					exit('验证码已失效，请重新验证');
				}else{
					C_base::M('admin.base')->yzm_d(array('id'=>$yz['id']));
					$t = array('id'=>$this->zjid);
					$xiu = C_base::M('admin.recruit')->user_u($t,$w);
					if($xiu){
						if($type == 1){//手机
							$this->Ses('recruit_zjia_sj','');
						}else{
							$this->Ses('recruit_zjia_yx','');
						}
						exit('修改成功');
					}else{
						exit('系统繁忙');
					}
				}
			}else{
				exit('验证码错误');
			}
		}else{
			if($pd['id'] == $this->zjid){
				exit('新账号不能和原账号相同');
			}else{
				exit('此账号已存在');
			}
		}
	}
/***************************************课程*******************************************/
	function kcgl(){
		$this->title = '课程管理';
		$page = $this->page = @$this->_get('page') ? $this->_get('page') : 1;
		$pagesize = $this->pagesize = 10;
		$this->rs =  C_base::M('admin.recruit')->sp_ss($this->zjid,array('zjid'=>$this->zjid),$page,$pagesize);
	}
	
	function kcfb(){
		$this->title = '课程发布';
		$this->sfdl_zjia();
	}
	
	function kcxg(){
		$this->title = '课程修改';
		$this->sfdl_zjia();
		$this->id = @$this->_get('id');
		if(@!$this->id){
			exit('非法操作');
		}
		$this->cz =  C_base::M('admin.recruit')->sp_s($this->zjid,array('id'=>$this->id,'zjid'=>$this->zjid));
		$this->cz['content'] = htmlspecialchars_decode($this->cz['content']);
		if(@!$this->cz){
			exit('此课程以失效');
		}
	}
	
	/**
	 * zjid 专家id
	 * type +/-
	 * zd 増减字段  fbsp/fbgw
	 */
	function  zjia_tongji($zjid,$type,$zd){
		$cz = C_base::M('admin.recruit')->zjtongji_s(array('zjid'=>$this->zjid));
		if($cz){
			C_base::M('admin.recruit')->zjtongji_u(array('zjid'=>$this->zjid),array($zd.$type=>1));
		}else{
			C_base::M('admin.recruit')->zjtongji_c(array('zjid'=>$this->zjid,$zd=>1));
		}
	}
	/**
	 * name  课程名称
	 * content  课程内容
	 * lb  类别 1视频2文章
	 * shipin 视频路径
	 * sp_kcjf 观看课程扣除积分
	 */
	function kcfb_sck(){
		extract($this->_post());
		$this->sfdl_zjia();
		$this->wszl();
		if(@$sp_kcjf < 0 || @!preg_match('/^[0-9]*$/', $sp_kcjf)){
			exit('扣除数量必须为不为负数的整数');
		}
		if(@$lb == 1){
			if(@!$shipin){
				exit('视频过大或格式不正确');
			}else{
				$shipin = str_replace('/',DS,@$shipin);
				if(strpos($shipin,DS.'upload'.DS.'zhuanjia') === false){     //使用绝对等于
					exit('视频过大或格式不正确');
				}
			}
		}else{
			$shipin = '';
		}
		$conn = self::pdwk(@$name);  //判断课程名称
		if(trim($conn)){
			if(@$id){ //修改
				$cz =  C_base::M('admin.recruit')->sp_s($this->zjid,array('name'=>$name,'zjid'=>$this->zjid,'id!'=>$id));
			}else{ //发布
				$cz =  C_base::M('admin.recruit')->sp_s($this->zjid,array('name'=>$name,'zjid'=>$this->zjid));
			}
			if(@$cz){
				exit('此课程已存在');
			}
			$con=(strlen(trim($conn)) + mb_strlen(trim($conn),'UTF8'))/2;
			if($con > 60){
				exit('名称不能超过60个字符【30个汉字】');
			}
		}else{
			exit('视频名称不能为空');
		}
		$data = array('name'=>$name,'content'=>htmlspecialchars($content),'shipin'=>@$shipin,'jifen'=>@$sp_kcjf,'zjid'=>$this->zjid,'time'=>time());
		if(@$id){//修改
			$gwc = C_base::M('admin.recruit')->sp_u(array('zjid'=>$this->zjid,'id'=>$id),$data);
		}else{//发布
			$gwc = C_base::M('admin.recruit')->sp_c($this->zjid,$data);
		}
		if(@$gwc){
			if(@!$id){
				self::zjia_tongji($this->zjid,'+','fbsp');
			}
			exit('cg');
		}else{
			exit('error');
		}
		
	}
	/**
	 * 专家 谁看过我的视频
	 */
	function who_look(){
		$this->sfdl_zjia();
		$this->title = '谁看过我的视频';
		$lx = $this->lx = @$this->_get('lx');
		$page = $this->page = @$this->_get('page') ? $this->_get('page') : 1;
		$pagesize = $this->pagesize = 10;
		if(@$lx){
			if($lx == '1'){  //3天内
				$qq = date("Y-m-d", strtotime("-3 day"));
				$aa = strtotime($qq.'23:59:59');
			}elseif ($lx == '2'){  //7天内
				$qq = date("Y-m-d", strtotime("-7 day"));
				$aa = strtotime($qq.'23:59:59');
			}elseif ($lx == '3'){  //30天内
				$qq = date("Y-m-d", strtotime("-30 day"));
				$aa = strtotime($qq.'23:59:59');
			}
			$w = array('time]'=>$aa,'time|'=>time());
		}
		if(@$w){
			$ww = array_merge($w,array('zjid'=>$this->zjid));
		}else{
			$ww = array('zjid'=>$this->zjid);
		}
		$rs = C_base::M('admin.recruit')->zjlook_ss($this->zjid,$ww,$page,$pagesize);
		if(@$rs['data']){ //获取who的姓名  学历  工作经验  视频的标题
			foreach ($rs['data'] as $k=>$v){
				$yh= C_base::M('admin.recruit')->user_s(array('id'=>$v['uid']));
				$sp= C_base::M('admin.recruit')->sp_s($this->zjid,array('id'=>$v['spid']));
				if(@$yh && @$sp){
					$rs['data'][$k]['lx'] = $yh['lx'];
					$pd = $this->zzxx($v['uid']);
					$rs['data'][$k]['name'] = $this->user_name($v['uid']); //名称
					$rs['data'][$k]['xueli'] = @$pd['xueli'] ? @$pd['xueli'] : '未知';  //学历
					$rs['data'][$k]['zttime'] = @$pd['zttime'] ? @$pd['zttime'] : '0';  //工作经验
					$rs['data'][$k]['spname'] = $sp['name'];
				}
			}
			$this->rs = $rs;
		}
	}
	
	function upfile(){//上传视频
		$this->title = '上传视频';
		$this->id = @$this->_get('id');//图片返回id
	}
	
	function uptp(){//上传图片
		$this->id = @$this->_get('id');
		$this->tpljs = $fz = self::scwj($this->zjid,$_FILES['sp_file']);
		if($fz == '0'){
			$this->tplj = '上传失败';
		}elseif($fz == '-1'){
			$this->tplj ='视频过大';
		}elseif ($fz == '-2'){
			$this->tplj ='视频上传出错';
		}elseif ($fz == '-3'){
			$this->tplj ='上传视频类型不被允许';
		}elseif ($fz == '-4'){
			$this->tplj ='没有选择文件';
		}else{
			$this->tplj = str_replace(DS,'/',@$this->tpljs);
		}
		
	}
	
	/**
	 * 上传视频
	 */
	function scwj($zjid,$spwj){
		extract($this->_get());
		$a = $spwj;
		//$a = $this->_file($spwj);
		if($a['error'] != 4){
			if($a['size'] > ($this->_filesize*1024*1024)){//判断文件大小是否符合规定上传大小
				return '-1';//上传文件超过 $this->_imgsize M
			}
			if($a['error'] == 1 || $a['error'] == 2){
				return '-1';//上传文件过大
			}elseif($a['error'] == 3 || $a['error'] == 5){
				return '-2';//文件上传出错
			}else{
				$hzm = explode('.',$a['name']);
				$g = $hzm[count($hzm)-1];
				if($this->if_file_type($g) == 1){
					$lj = WEB_DIR.'upload'.DS.'zhuanjia'.DS.$zjid;
					$luji = file_exists($lj);
					if(empty($luji)){
						mkdir($lj,0777);
					}
					$ml = $lj.DS.md5($a['name']).'.'.$hzm[count($hzm)-1];
					$llj =DS.'upload'.DS.'zhuanjia'.DS.$zjid.DS.md5($a['name']).'.'.$hzm[count($hzm)-1];
					if(!file_exists($ml)){
						$b = move_uploaded_file($a['tmp_name'],$ml);
					}else{
						$b=1;
					}
					if($b){
						return $llj;
					}else{
						return '0';//上传失败
					}
				}else{
					return '-3';//上传附件类型不被允许
				}
			}
		}else{
			return '-4';//没有选择文件
		}
	}

	function if_file_type($file_type){
		$file_type = strtolower($file_type);	//全部转小写
		if (in_array($file_type, $this->file_type)) {
			return '1';
		}else{
			return '';
		}
	}

	function kcxx(){
		$this->title = '课程详情';
		$this->spid = $this->_get('spid');
		$zjid = $this->did = @$this->_get('zjid');
		if(@!$this->spid || @!$zjid){
			$this->_cuowu('非法操作');
		}
		$this->user = C_base::M('admin.recruit')->user_s(array('id'=>$zjid));
		if($this->user['lx'] == 1){
			$qy = C_base::M('admin.recruit')->qys_s(array('uid'=>$this->user['qyid']));
			$this->user['qyname'] = @$qy['qy_name'];
			$this->base = C_base::M('admin.recruit')->ubase_s(array('uid'=>$zjid));
			$zy = C_base::M('admin.recruit')->major_s(array('id'=>@$this->base['zhuanye']));
			$this->base['zhuanye'] = $zy['name'];
		}elseif($this->user['lx'] == 2){
			$this->base = C_base::M('admin.recruit')->vbase_s(array('uid'=>$zjid));
		}else{
			$this->_cuowu('过期数据');
		}
		if($this->zjid == @$zjid){   //自己看自己
			$this->rs =  C_base::M('admin.recruit')->sp_s($this->zjid,array('id'=>$this->spid));
			$this->zj =1;
		}else{  //别人[用户]看
			if(@!$this->uid){
				$this->_alert_location($this->_url,'个人登录后，方可查看');
			}
			$user = C_base::M('admin.recruit')->user_s(array('id'=>$this->uid));
			$rs =  C_base::M('admin.recruit')->sp_s($zjid,array('id'=>$this->spid,'zt'=>1,));
			if($user && $rs){
				$w = array('uid'=>$this->uid,'zjid'=>$zjid,'spid'=>$this->spid);
				$look= C_base::M('admin.recruit')->look_s($this->uid,$w);
				if(@$look){  //之前观看过不扣除积分 更改观看时间
					$this->rs =$rs;
					C_base::M('admin.recruit')->look_u($w,array('time'=>time()));
				}else{ //用户-积分，专家+积分，浏览次数+1，最后观看时间更改
					if($user['jifen'] >= $rs['jifen']){
						$w['time'] = time();
						if($rs['shipin']){
							$w['lx'] =1;
						}
						if($user['slevel'] == 0){//接受过线上培训
							C_base::M('admin.recruit')->user_u(array('id'=>$this->uid),array('slevel'=>1));
						}
						C_base::M('admin.recruit')->user_u(array('id'=>$this->uid),array('jifen-'=>$rs['jifen'])); //扣除积分
						C_base::M('admin.recruit')->look_c($this->uid,$w);  //写入个人观看记录
						C_base::M('admin.recruit')->user_u(array('id'=>$zjid),array('jifen+'=>$rs['jifen'])); //增加上传人积分
						C_base::M('admin.recruit')->sp_u(array('zjid'=>$zjid,'id'=>@$this->spid),array('ckcs+'=>1)); //课程浏览数+1
						$this->rs = $rs;
					}else{
						$this->_alert_location($this->_url.'/?act=ruser&met=czjf','积分不足了，快去充值吧');
					}
				}
				self::pu_vip($zjid);
				//谁看过我的视频
				$c = array('zjid'=>$zjid,'uid'=>$this->uid,'spid'=>$this->spid);
				$zjcz = C_base::M('admin.recruit')->zjlook_s($zjid,$w);
				if(@$zjcz){ //存更新时间
					C_base::M('admin.recruit')->zjlook_u($w,array('time'=>time()));
				}else{
					$c['time']=time();
					C_base::M('admin.recruit')->zjlook_c($zjid,$c);
				}
				//如果是系统通知,则执行以下步骤
				if(@$this->_get('id')){//通知id
					C_base::con('html.ruser')->tzxx($this->_get('id'));
				}
			}else{
				$this->_cuowu('系统繁忙');
			}
			$aa = str_replace(DS,'/',@$this->rs['shipin']);
			$this->lj =$this->_url.$aa;
		}
		$page = $this->page = @$this->_get('page') ? $this->_get('page') : 1;
		$pagesize = $this->pagesize = 10;
		$this->plss = self::pl_ss($this->spid,$zjid,$page,$pagesize); //课程评论
	}
	

	
/****************课程评论【lmid：1】*********************/
	function user_name($uid,$type=0){//获取用户名
		$yh = C_base::M('admin.recruit')->user_s(array('id'=>$uid));
		if($type == 1){//只获取注册时的账号
			$yhm = $yh['phone'] ? $yh['phone'] : $yh['email'];
			return $yhm;
		}else{//有姓名获取姓名，没有姓名获取注册时的账号
			$user = $this->zzxx($uid);
			$yhm = @$yh['phone'] ? $yh['phone'] : @$yh['email'];
			$name = @$user['name'] ? $user['name'] : $yhm;
			return $name;
		}
	}
	
	function kc_pinglun(){
		$this->title = '课程评论';
		$this->did = @$this->_get('did');
		$this->spid = @$this->_get('spid');
		$this->hpid = @$this->_get('hid');
		$uid = @$this->Ses('recruit_uid') ? $this->Ses('recruit_uid') : $this->Ses('recruit_zjid');
		if(@!$uid){
			exit('请登录');
		}
		$this->name = $this->user_name($uid,0);
	}
	
	/**
	 * 写入评论和回复
	 */
	function pl_c(){
		$this->_is_html = 1;
		$hfid = @$this->Ses('recruit_uid') ? $this->Ses('recruit_uid') : $this->Ses('recruit_zjid');
		if(@!$hfid){
			exit('请登录');
		}
		extract($this->_post());
		$content = str_replace(' ','',str_replace('　','',@$content));
		if(empty($content)){
			exit('内容不能为空');//评论内容不能为空
		}
		$ns = C_base::dybase('util')->zfpd($content, '300','');
		if ($ns == '-1'){
			exit('评论内容最多150个汉字!');
		}
		if($hpid){
			$ps = C_base::M('admin.pinglungl')->pinglun_s($zid,array('id'=>$hpid));
			if(@$ps['hdid']){
				$plid= $ps['plid'];
			}else{
				$plid= $ps['id'];
			}		
			$hdid = $ps['hfid'];
		}
		if($hfid == $hdid){
			exit('自己不能回复自己');
		}
		$c = array('lmid'=>$lmid,'zid'=>$zid,'uid'=>$uid,'plid'=>$plid,'hfid'=>$hfid,'hdid'=>$hdid,'content'=>$content,'time'=>time());
		$r = C_base::M('admin.pinglungl')->pinglun_c($zid,$c);
		if(@$r){
			exit('cg');
		}else{
			exit('error');
		}
	}
	
	function pl_ss($zid,$uid,$page,$pagesize){
		$plss = C_base::M('admin.pinglungl')->pinglun_ss($zid,array('zid'=>$zid,'uid'=>$uid,'hdid'=>0),$page,$pagesize);
		if(@$plss['data']){
			$pl = array();
			foreach($plss['data'] as $k=>$v){
				$pl['data'][$k] = $v;
				$base = $this->zzxx($v['hfid']);
				$pl['data'][$k]['touxiang'] = @$base['touxiang'] ? $base['touxiang'] : '';
				$pl['data'][$k]['name'] =$this->user_name($v['hfid']);
				$hf = C_base::M('admin.pinglungl')->pinglun_ss($zid,array('zid'=>$zid,'uid'=>$uid,'plid'=>$v['id']));
				if(@$hf){
					foreach ($hf as $k1=>$v1){
						$base1 = $this->zzxx($v1['hfid']);
						$base2 = $this->zzxx($v1['hdid']);
						$pl['data'][$k]['hf'][$k1] = $v1;
						$pl['data'][$k]['hf'][$k1]['hftx'] = @$base1['touxiang'] ? $base1['touxiang'] : '';
						$pl['data'][$k]['hf'][$k1]['hdtx'] = @$base2['touxiang'] ? $base2['touxiang'] : '';
						$pl['data'][$k]['hf'][$k1]['hfname'] =$this->user_name($v1['hfid']);
						$pl['data'][$k]['hf'][$k1]['hdname'] =$this->user_name($v1['hdid']);
					}
				}
			}
			$pl['count'] = $plss['count'];
			return $pl;
		}
	}
	
	/**
	 * 删除评论
	 * zid 视频id
	 * id 评论id
	 */
	function pl_del(){  
		$this->_is_html = 1;
		extract($this->_post());
		$w = array('id'=>$id,'zid'=>$zid);
		$cz = C_base::M('admin.pinglungl')->pinglun_s($zid,$w);
		if(@!$cz['hdid']){
			C_base::M('admin.pinglungl')->pinglun_del($zid,array('plid'=>$cz['id']));
		}
		if($cz){
			$del = C_base::M('admin.pinglungl')->pinglun_d($zid,$w);
			if(@$del){
				exit('删除成功');
			}else{
				exit('error');
			}
		}else{
			exit('此评论已失效');
		}
	}
/**************************************简历***************************************/
	/**
	 * 专家下载过的简历
	 */
	function jlgl(){
		$this->sfdl_zjia();
		$this->title = '简历管理-下载的简历';
		$page = $this->page = @$this->_get('page') ? $this->_get('page') : 1;
		$pagesize = $this->pagesize = 10;
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		if($yh['lx'] == 1){  //普通专家
			if(@$yh['qyid']){
				$rs =  C_base::M('admin.recruit')->jlxz_ss($yh['qyid'],array('lx'=>1,'qid'=>$yh['qyid']),$page,$pagesize);
			}
		}elseif($yh['lx'] == 2){ //VIP
			$rs =  C_base::M('admin.recruit')->jlxz_ss($yh['id'],array('qid'=>$yh['id']),$page,$pagesize);
		}else{
			$this->_cuowu('error');
		}
		if(@$rs['data']){
			$w = self::jlsous();
			$yx =array();
			foreach ($rs['data'] as $k=>$v){  //获取简历详情
				if(@$w){
					$ww = array_merge($w,array('id'=>$v['jlid']));
				}else{
					$ww = array('id'=>$v['jlid']);
				}
				$jlxx = C_base::M('admin.recruit')->resume_s($v['uid'],$ww);
				if($jlxx){
					$yx[$k] = $v;
					$yx[$k]['jlxx'] = $jlxx;
					$zw = C_base::M('admin.recruit')->job_s(array('id'=>$jlxx['zhiwei']));
					$yx[$k]['zw'] = $zw['name'];   //职位
					
				}
			}
			$this->rscount = $rs['count'];
			$this->rs = @$yx;
		}
	}
	
	
	/**
	 * 删除下载的简历
	 * id 简历历史id
	 * qid 下载企业id
	 */
	function jlls_del(){
		$this->sfdl_zjia();
		$this->_is_html =1;
		extract($this->_post());
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		if($yh['lx'] == 1){
			if($yh['qyid'] !=$qid){
				exit('非法操作');	
			}
			$aa = C_base::M('admin.recruit')->jlxz_s($qid,array('id'=>$id,'qid'=>$qid,'lx'=>1));
		}elseif($yh['lx'] == 2){
			if($this->zjid !=$qid){
				exit('非法操作');
			}
			$aa = C_base::M('admin.recruit')->jlxz_s($qid,array('id'=>$id,'qid'=>$qid));
		}
		if(@$aa){
			$bb = C_base::M('admin.recruit')->jlxz_d($qid,array('id'=>$id,'qid'=>$qid));
			if($bb){
				exit('cg');
			}else{
				exit('error');
			}
		}else{
			exit('下载历史已过期');
		}
	}
	
	/**
	 * 简历管理-收到的简历vip
	 */
	function jlgl_vipsd(){
		$this->title = '简历管理-收到的简历';
		$this->sfdl_zjia();
		$page = $this->page = @$this->_get('page') ? $this->_get('page') : 1;
		$pagesize = $this->pagesize = 10;
		$rs =  C_base::M('admin.recruit')->vtoudi_ss($this->zjid,array('zjid'=>$this->zjid),$page,$pagesize);
		
		if(@$rs['data']){
			$w = self::jlsous();
			$rss['data'] = util::paixu($rs['data'],'zt');
			foreach ($rss['data'] as $k=>$v){
				if(@$w){
					$ww = array_merge($w,array('id'=>$v['jid']));
				}else{
					$ww = array('id'=>$v['jid']);
				}
				$jlxx = C_base::M('admin.recruit')->resume_s($v['uid'],$ww);
				$qwxx = C_base::M('admin.recruit')->qy_gw_s($this->zjid,array('id'=>$v['zid']));
				if(@$jlxx && $qwxx){
					$this->rs['data'][$k] =$v;
					$user = C_base::M('admin.recruit')->ubase_s(array('uid'=>$v['uid']));
					$this->rs['data'][$k]['name'] =$jlxx['name'];
					$this->rs['data'][$k]['age'] = $jlxx['age'];
					$this->rs['data'][$k]['xueli'] = $jlxx['xueli'];
					$this->rs['data'][$k]['sex'] = $jlxx['sex'];
					$this->rs['data'][$k]['gwname'] = $qwxx['name'];
				}				
			}
			$this->rs['count'] = $rs['count'];
		}
	}
	/**
	 * 按条件查询下载/收到的简历
	 */
	function jlsous(){
		$yx = array();
		if(@$this->_get('lx')){   //搜索
			$gjz = @$this->_get('gjz');
			if($this->_get('lx') == 1){  //名称
				$w = array('name?'=>$gjz);
			}elseif($this->_get('lx') == 2){  //年龄
				$w = array('age'=>$gjz);
			}elseif($this->_get('lx') == 3){  //学历
				$w = array('xueli'=>$gjz);
			}else{
				$w = array();
			}
			return $w;
		}
	}
	
	/**
	 * 删除收到的简历历史vip
	 * jlid 简历历史id
	 */
	function jlsd_del(){
		$this->sfdl_zjia();
		$this->_is_html =1;
		$jlid = @$this->_post('jlid');
		if(@!$jlid){
			exit('系统繁忙');
		}
		$rs =  C_base::M('admin.recruit')->vtoudi_s($this->zjid,array('id'=>$jlid));
		if($rs){
			$dd =  C_base::M('admin.recruit')->vtoudi_d($this->zjid,array('id'=>$jlid));
			if($dd){
				exit('cg');
			}else{
				exit('error');
			}
		}else{
			exit('该简历以过期');
		}
	}

	function vip_jlstj(){
		$this->title= '简历数统计';
		if(@$this->zjid && @$this->Ses('firm_id')){
			$this->_cuowu('系统异常');
		}
		$this->rs = C_base::M('admin.xitonggl')->tc_ss(array());
	}
	
	function jlgm(){  
		$this->title ='支付方式';
		$this->type = @$this->_get('type');
	}
/************************************职位管理******************************************/
	function zjgw_gl(){
		$this->sfdl_zjia();
		$this->title='职位管理';
		$this->type = @$this->_get('type');
		$this->rs = self::zwlx($this->zjid,$this->type);
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		if($yh['lx'] == 1){
			$this->qid = @$yh['qyid'];
		}
	}
	
	function zwlx($zjid,$type='',$pasize=''){
		$page = $this->page = @$this->_get('page') ? $this->_get('page') : 1;
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$zjid));
		if(@$type == 1){  //未发布的职位
			$w = array('issue'=>2);
			$px = 'asc';
		}elseif (@$type == 2){ //已停止的职位
			$w = array('issue'=>0);
			$px = 'desc';
		}else{ //正在发布的
			$w = array('issue'=>1,'jstime>'=>time());
			$px = 'asc';
		}
		if(@$yh['lx'] == 2){  //vip
			$ww = array_merge($w,array('style'=>2));
			$qid = $yh['id'];
		}else{
			if(@$yh['qyid']){
				$ww = array_merge($w,array('style'=>1));
				$qid = $yh['qyid'];
			}
		}
		if(@$pasize){
			$rs =  C_base::M('admin.recruit')->qy_gw_ss_p(@$qid,@$ww,$page,$pasize);
		}else{
			$rs =  C_base::M('admin.recruit')->qy_gw_ss(@$qid,@$ww);
		}
		if(@$px){
			return util::paixu($rs,'jstime',$px);
		}else{
			return $rs;
		}
	}
	function zjgw_fb(){
		$this->sfdl_zjia();
		$this->wszl();
		$this->title='职位发布-全职';
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		if ($yh['dongjie'] == '1'){
			$this->_cuowu('账号已冻结,请联系客服!');
		}
		if($yh['lx'] == 1){
			$pd = C_base::M('admin.recruit')->qy_s(array('id'=>$yh['qyid']));
			if (@$pd['zt'] != '1'){
				$this->_cuowu('该关联企业账号未激活或已冻结,请联系企业!');
			}
		}
		$this->hy =  C_base::M('admin.recruit')->job_ss(array('sid'=>0));//职位类别
		$this->ssq = C_base::M('admin.port')->linkage_ss(array('parent_id'=>'0'));
	}
	
	function zjgw_fbjz(){
		$this->sfdl_zjia();
		$this->zjgw_fb();
		$this->title='职位发布-兼职';
	}
	
	function gwsx(){//刷新岗位
		$this->_is_html = 1;
		$this->sfdl_zjia();
		extract($this->_post());
		$uid = $this->hq_uid();
		if(@$id){
			$w = array('id'=>$id);
			$u = array('utime'=>time());
			$xg = C_base::M('admin.recruit')->qy_gw_u($uid,$w,$u);
			if($xg == '1'){
				exit('刷新成功');
			}else{
				exit('刷新失败!');
			}
		}else{
			exit('刷新失败!');
		}
	}
	
	function fbgw_pd($post){ //发布岗位判断
		extract($post);
		if ($zt == '0'){
			if (@$xueli){
				$xl = C_base::dybase('util')->zfpd($xueli, '1','','1');
				if($xl == '-1'){
					exit('请选择学历!');
				}
			}else {
				exit('请填写学历!');
			}
			$jy = C_base::dybase('util')->zfpd($gzjy,'4','','1');
			if ($jy == '-1'){
				exit('请选择工作经验!');
			}
		}elseif ($zt == '1'){
			if (@$jztime == ''){
				exit('请选择兼职时间!');
			}
		}
		$n = C_base::dybase('util')->zfpd($name, '4','','1');
		if ($n == '-1'){
			exit('岗位名称最少2个汉字!');
		}
		$ns = C_base::dybase('util')->zfpd($name, '30','');
		if ($ns == '-1'){
			exit('岗位名称最多15个汉字!');
		}
		$zw = C_base::dybase('util')->zfpd($zwlb, '1','','1');
		if ($zw == '-1'){
			exit('请选择职位类型!');
		}
		$nu = C_base::dybase('util')->zfpd($number, '1','','1');
		if ($nu == '-1'){
			exit('请填写招聘人数!');
		}
		if (!preg_match('/^[1-9]\d*|0$/', $number)) {//只能为数字
			exit('招聘人数只能为数字!');
		}
		$lxr = C_base::dybase('util')->zfpd($linkman, '2','','1');
		if ($lxr == '-1'){
			exit('联系人最少为2个字符!');
		}
		$lxrs = C_base::dybase('util')->zfpd($linkman, '30','');
		if ($lxrs == '-1'){
			exit('联系人最多为30个字符!');
		}
		if($zt == 0){
			$dd = C_base::dybase('util')->zfpd($address, '4','','1');
			if ($dd == '-1'){
				exit('工作地点不能小于2个字!');
			}
			$dd = C_base::dybase('util')->zfpd($address, '60','');
			if ($dd == '-1'){
				exit('工作地点不能大于30个字!');
			}
		}
		$p = util::preg_phone($phone);
		if (!$p){
			exit('手机号错误!');
		}
		if (@$email){
			$e = util::preg_email($email);
			if (!$e){
				exit('邮箱格式错误!');
			}
		}
	}
	function zjfb_sck(){
		$this->_is_html = 1;
		$this->sfdl_zjia();
		$this->wszl();
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		extract($this->_post());
		if (@$zt!='' && @$name && @$zwlb && @$zhiwei && @$number && @$money && @$sheng && @$shi &&
		 @$linkman /* && @$address  */&& @$phone){
			self::fbgw_pd($this->_post());
			$arr = util::quchu($this->_post(), 'jstime');
			if(@$jstime){
				if(strtotime(@$jstime) <= time()){
					exit('招聘结束时间不得小于当前时间');
				}
				$arr['jstime'] = strtotime(@$jstime);
			}else{
				$arr['jstime'] = strtotime("3 month");  //默认三个月
			}
			if(@$zt == '1'){
				$arr['stay'] =2;
			}
			if($yh['lx'] == 1){  //普通专家
				$qid = $yh['qyid'];
				$qyxx = C_base::M('admin.recruit')->qys_s(array('uid'=>$qid));
				$arr['sshy'] = $qyxx['sshy'];
				$arr['qyxz'] = $qyxx['qyxz'];
				$arr['qy_name'] = $qyxx['qy_name'];
				$arr['qid'] = $qid;
				$arr['style'] = 1;
				$arr['time'] = time();
				$xr = C_base::M('admin.recruit')->qy_gw_c($qid,$arr);
			}elseif($yh['lx'] == 2){  //VIP专家
				//$arr['sshy'] = @$sshy;
				$arr['qyxz'] = '私营';
				$vbase = C_base::M('admin.recruit')->vbase_s(array('uid'=>$this->zjid));
				$arr['qy_name'] = $vbase['name'];
				$arr['qid'] = $this->zjid;
				$arr['style'] = 2;
				$arr['time'] = time();
				$xr = C_base::M('admin.recruit')->qy_gw_c($this->zjid,$arr);
			}else{
				exit('非法操作');
			}			
			if ($xr){
				self::zjia_tongji($this->zjid,'+','fbgw');  //专家发布职位数+1
				//普通专家关联企业职位发布数+1
				if(@$this->Ses('zclx') == 1){
					C_base::con('html.firm')->gwtj(@$yh['qyid'],'yfb','1');
				}
				exit('发布成功!');
			}else {
				exit('发布失败!');
			}
		}else {
			exit('请完善发布信息!');
		}
	}
	
	function hq_uid(){
		$this->sfdl_zjia();
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		if(@$yh['lx'] == 2){  //vip
			$qid = $yh['id'];
		}else{
			if(@$yh['qyid']){
				$qid = $yh['qyid'];
			}
		}
		return @$qid;
	}
	/**
	 * 修改截止时间
	 * id 职位id
	 */
	function zjgw_xgjstime(){
		$this->sfdl_zjia();
		extract($this->_get());
		$this->title = '修改职位状态';
		$uid = $this->hq_uid();
		$this->cz = C_base::M('admin.recruit')->qy_gw_s($uid,array('qid'=>$uid,'id'=>$id));
	}
	
	/**
	 * 停止发布职位
	 * id 职位id
	 */
	function zjgw_tzfb(){
		$this->_is_html = 1;
		$this->sfdl_zjia();
		extract($this->_post());
		$uid = $this->hq_uid();
		$w = array('qid'=>$uid,'id'=>$id);
		$cz = C_base::M('admin.recruit')->qy_gw_s($uid,$w);
		if(@$cz){
			if(@$type == 1){ //修改职位状态
				if(@$jstime){
					if(strtotime(@$jstime) < time()){
						exit('结束时间不得小于当前时间');
					}
					$u = array('jstime'=>strtotime(@$jstime),'issue'=>@$issue);
				}else{
					if($cz['jstime'] < time()){
						exit('结束时间不得小于当前时间');
					}
					$u = array('issue'=>@$issue);
				}
				$wz = '修改';
			}else{ //停止
				$u = array('issue'=>0);
				$wz = '停止';
			}
			$xiu = C_base::M('admin.recruit')->qy_gw_u($uid,$w,$u);
			if($xiu){
				exit($wz.'成功');
			}else{
				exit($wz.'失败');
			}	
		}else{
			exit('error');
		}	
	}
	


/********职位置顶，暂时不要*************/
	/**
	 * 职位指定
	 */
	function zjgw_zding(){
		$this->title ='职位置顶';
		$this->sfdl_zjia();
		$yh= C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		$w = array('issue'=>1,'jstime>'=>time());
		$page = $this->page = @$this->_get('page') ? $this->_get('page') : 1;
		$pagesize = $this->pagesize = 10;
		if($yh['lx'] == 2){  //vip
			$ww = array_merge($w,array('style'=>2));
			$qid = $yh['id'];
		}else{
			if($yh['qyid']){
				$ww = array_merge($w,array('style'=>1));
				$qid = $yh['qyid'];
			}
		}
		$this->rs =  C_base::M('admin.recruit')->qy_gw_ss($qid,$ww,$page,$pagesize);
	}
	
	/**
	 * 批量删除职位
	 * zwid 职位id字符串
	 */
	function zjgw_del(){
		$this->_is_html = 1;
		$this->sfdl_zjia();
		extract($this->_post());
		$uid = $this->hq_uid();
		if(@$id){
			$aa = C_base::M('admin.recruit')->qy_gw_d($uid,array('qid'=>$uid,'id'=>$id));
		}elseif(@$zwid){
			$arr = array_filter(explode(',', $zwid));
			if(@$arr){
				foreach ($arr as $k=>$v){
					$w = array('qid'=>$uid,'id'=>$v);
					$cz =  C_base::M('admin.recruit')->qy_gw_s($uid,$w);
					if($cz){
						$aa = C_base::M('admin.recruit')->qy_gw_d($uid,$w);
					}
				}
			}
		}else{
			exit('请选择职位');
		}
		if(@$aa){
			exit('删除成功');
		}else{
			exit('error');
		}
	}
		
/************************************聊天IM**************************************/
	function liaot(){
		$this->title='聊天';
		if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8.0') || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7.0') || strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6.0')) {
			$this->_cuowu('当前浏览器版本太低，请升级版本后进入');
		}
		$this->did = @$this->_get('uid');
		$duser = C_base::M('admin.recruit')->user_s(array('id'=>$this->did));
		if(@$duser['lx'] != 0){
			$this->user = C_base::M('admin.recruit')->user_s(array('id'=>$this->did));
		}else{
			$this->user = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		}
		$this->dzl = $this->zzxx($this->did);
		if($this->uid){
			$this->zjzl = $this->dzl;
		}else{
			$this->zjzl = $this->zzxx($this->zjid);
		}				
		if($this->uid){
			$this->yhzl = $this->zzxx($this->uid);
			$zy = C_base::M('admin.recruit')->major_s(array('id'=>@$this->yhzl['zhuanye']));
			$this->yhzl['zy_name'] = @$zy['name'];
		}
		$user = C_base::M('admin.recruit')->user_s(array('id'=>$this->zjid));
		if(@$user['ltlx'] == 1){  //单聊获取列表
			$this->rlb = C_base::M('admin.recruit')->room_ss(array('room'=>$this->zjid));
			if(@$this->rlb){
				foreach ($this->rlb as $k=>$v){
					$this->rlb[$k]['uname'] = $this->user_name($v['uid']);
				}
			}
		}
	}

	/**
	 * type 1 一对一 2一对多
	 */
	function ltlx(){
		$this->_is_html =1;
		$this->sfdl_zjia();
		extract($this->_post());
		$xiu = C_base::M('admin.recruit')->user_u(array('id'=>$this->zjid),array('ltlx'=>@$type));
		if($xiu){
			if($type == 1){
				exit('当前聊天模式为一对一模式');
			}else{
				$cz = C_base::M('admin.recruit')->room_s(array('uid'=>$this->zjid,'room'=>$this->zjid));
				if(@!$cz){
					C_base::M('admin.recruit')->room_c(array('uid'=>$this->zjid,'room'=>$this->zjid));
				}
				exit('当前聊天模式为一对多模式');
			}
		}else{
			exit('系统异常');
		}
	}
/*************************************其他接口*****************************************/	
	/**
	 * API
	 * 普通升级vip
	 * uid 用户id
	 */
	function pu_vip($uid){
		$user = C_base::M('admin.recruit')->user_s(array('id'=>$uid));
		if(@$user && @$user['qyid']){
			if($user['lx'] == 1){  //普通专家
				if($user['jifen'] >= 3){  //积分大于200升级为vip [专家类型改为2，与企业解除关系  去除用户表中的企业id 去除企业表中的专家id]
					$xxg = C_base::M('admin.recruit')->qys_u(array('uid'=>$user['qyid']),array('zid'=>0));
					$xg = C_base::M('admin.recruit')->user_u(array('id'=>$uid),array('lx'=>2,'qyid'=>0));
					if(@$xxg && @$xg){
						$base = C_base::M('admin.recruit')->ubase_s(array('uid'=>$uid));
						if($base){
							$vbase = C_base::M('admin.recruit')->vbase_s(array('uid'=>$uid));
							$up = util::quchu($base,'bytime,hksheng,hkshi,hkqu,hk,zhuangtai,zttime,hyzt,xueli,zhuanye,waiyu,zzmm,qq,grzy');
							if(@$base['email']){
								$up['email'] = $base['email'];
							}
							if(@$vbase){  //xiu
								C_base::M('admin.recruit')->vbase_u(array('uid'=>$uid),$up);
							}else{  //xie
								$up['uid'] = $uid;
								C_base::M('admin.recruit')->vbase_c($up);
							}
						}
					}
				}
			}
		}
		return false;
	}

	
	function gmtczf(){
		require_once ('../sys/base/zfb/alipay.config.php');
		require_once ('../sys/base/zfb/lib/alipay_submit.class.php');
		$type = $this->_post('type');
		if(@!$type){
			exit('系统异常');
		}else{
			$cc = C_base::M('admin.xitonggl')->tc_s(array('id'=>$type));
			if($cc){
				$uid= @$this->Ses('recruit_zjid') ? $this->Ses('recruit_zjid') : @$this->Ses('firm_id');
				if(!$uid){
					exit('系统异常');
				}
				$mo = C_base::M('admin.xitonggl')->tc_s(array('id'=>$type));
				
				if(@$this->Ses('recruit_zjid')){
					$lx = 1;
					$return_url = 'http://www.sky9001.com/?act=job';
				}else{
					$lx = 2;
					$return_url = 'http://www.sky9001.com/?act=firm';
				}
				$parameter = array(
						"service" => "create_direct_pay_by_user",
						"partner" => trim($alipay_config['partner']),
						"seller_email" => trim($alipay_config['seller_email']),
						"payment_type"	=> 1, //支付类型 不能修改
						"notify_url"	=> 'http://www.sky9001.com/notify_url.php', //服务器异步通知页面路径
						"return_url"	=> $return_url, //页面跳转同步通知页面路径
						"out_trade_no"	=> $type.'-'.$lx.'-'.$uid.'-'.time(), //商户订单号
						"subject"	=> '购买套餐', //订单名称
						"total_fee"	=> $mo['money'], //付款金额
						"body"	=> $mo['name'], //订单描述
						"_input_charset"	=> trim(strtolower($alipay_config['input_charset'])) //字符编码格式 目前支持 gbk 或 utf-8
				);
				$alipaySubmit = new AlipaySubmit($alipay_config);
				$html_text = $alipaySubmit->buildRequestForm($parameter,"get", "下一步",'1');
				print_r($html_text);exit;
			}
		}
	}
	
	function sys(){  //微信充值【购买套餐】
		$type = $this->_get('type');
		if(@!$type){
			exit('系统异常');
		}else{
			$cc = C_base::M('admin.xitonggl')->tc_s(array('id'=>$type));
			if($cc){
				$uid= @$this->Ses('recruit_zjid') ? $this->Ses('recruit_zjid') : @$this->Ses('firm_id');
				if(!$uid){
					exit('系统异常');
				}
				$mo = C_base::M('admin.xitonggl')->tc_s(array('id'=>$type));
				if($this->Ses('recruit_zjid')){
					$lx = 1;
				}else{
					$lx = 2;
				}
				$money = $mo['money']*100;
				C_base::yn_file('base'.DS.'ceshi'.DS.'WxPayPubHelper'.DS.'WxPayPubHelper.php');
				//使用统一支付接口
				$unifiedOrder = new UnifiedOrder_pub();
				//设置统一支付接口参数
				//设置必填参数
				$unifiedOrder->setParameter("body","购买套餐");//商品描述
				//自定义订单号，此处仅作举例
				$out_trade_no = $type.'-'.$lx.'-'.$uid.'-'.time();
				//$out_trade_no = WxPayConf_pub::APPID."$timeStamp";
				$unifiedOrder->setParameter("out_trade_no","$out_trade_no");//商户订单号
				$unifiedOrder->setParameter("total_fee",$money);//总金额
				$unifiedOrder->setParameter("notify_url",WxPayConf_pub::NOTIFY_URL);//通知地址
				$unifiedOrder->setParameter("trade_type","NATIVE");//交易类型
				//获取统一支付接口结果

				$unifiedOrderResult =$this->unifiedOrderResult= $unifiedOrder->getResult();
				//商户根据实际情况设置相应的处理流程
				if ($unifiedOrderResult["return_code"] == "FAIL")
				{
					//商户自行增加处理流程
					echo "通信出错：".$unifiedOrderResult['return_msg']."<br>";
				}
				elseif($unifiedOrderResult["result_code"] == "FAIL")
				{
					//商户自行增加处理流程
					echo "错误代码：".$unifiedOrderResult['err_code']."<br>";
					echo "错误代码描述：".$unifiedOrderResult['err_code_des']."<br>";
				}
				elseif($unifiedOrderResult["code_url"] != NULL)
				{
					//从统一支付接口获取到code_url
					$this->code_url = $unifiedOrderResult["code_url"];
					//商户自行增加处理流程
					//......
				}
			}
		}
	}
	
	/**
	 * 套餐购买支付成功后执行方法
	 * type 支付套餐 1季度 2半年 3年
	 * lx 1专家 2企业
	 * uid  用户id
	 * dx 0支付宝 1微信
	 */
	function gmcg($type,$lx,$uid,$dx='0'){
		if(!$uid){
			return false;
		}
		$mo = C_base::M('admin.xitonggl')->tc_s(array('id'=>@$type));
		if($lx == 1){  //专家
			$xx = C_base::M('admin.recruit')->dingdan_c($uid,array('uid'=>$uid,'sty'=>$lx,'money'=>$mo['money'],'lx'=>$dx,'time'=>time()));
			$tongji = C_base::M('admin.recruit')->zjtongji_s(array('zjid'=>$uid));
			if($tongji){
				$da = array('jlfs+'=>$mo['kxz'],'jlgmfs+'=>$mo['kxz'],'kfb+'=>$mo['kfb']);
				if(@$type == 1){  //季度
					$da['yxjstime'] = $tongji['yxjstime'] + strtotime("3 month");
				}elseif (@$type == 2){  //半年
					$da['yxjstime'] = $tongji['yxjstime'] + strtotime("6 month");
				}elseif (@$type == 3){  //年
					$da['yxjstime'] = $tongji['yxjstime'] + strtotime("1 years");
				}
				$xx = C_base::M('admin.recruit')->zjtongji_u(array('zjid'=>$uid),$da);
			}else{
				$da = array('zjid'=>$uid,'yxkstime'=>time(),'fenzu'=>@$type,'jlgmfs'=>$mo['kxz'],'kfb'=>$mo['kfb']);
				if($type == 1){  //季度
					$da['yxjstime'] = strtotime("3 month");
				}elseif ($type== 2){  //半年
					$da['yxjstime'] = strtotime("6 month");
				}elseif ($type == 3){  //年
					$da['yxjstime'] = strtotime("1 years");
				}
				$xx = C_base::M('admin.recruit')->zjtongji_c($da);
			}
		}else{  //qiye
			$tongji = C_base::M('admin.recruit')->qy_gw_tj_s(array('qid'=>$uid));
			if($tongji){
				$da = array('kxzjl+'=>$mo['kxz'],'kfb+'=>$mo['kfb']);
				if(@$type == 1){  //季度
					$da['yxjstime'] = $tongji['yxjstime'] + strtotime("3 month");
					$l = '2';
				}elseif (@$type == 3){  //年
					$da['yxjstime'] = $tongji['yxjstime'] + strtotime("1 years");
					$l = '3';
				}
				$xgs = C_base::M('admin.recruit')->qyzcjl_c(array('qid'=>$uid,'lx'=>$l,'je'=>$mo['money'],'time'=>time()));
				$xx = C_base::M('admin.recruit')->qy_gw_tj_u(array('qid'=>$uid),$da);
			}else{
				$da = array('qid'=>$uid,'kxzjl'=>$mo['kxz'],'kfb'=>$mo['kfb']);
				if($type == 1){  //季度
					$da['yxjstime'] = strtotime("3 month");
					$l = '2';
				}elseif ($type == 3){  //年
					$da['yxjstime'] = strtotime("1 years");
					$l = '3';
				}
				$xgs = C_base::M('admin.recruit')->qyzcjl_c(array('qid'=>$uid,'lx'=>$l,'je'=>$mo['money'],'time'=>time()));
				$xx = C_base::M('admin.recruit')->qy_gw_tj_c($da);
			}
		}
	}
}